﻿using System;
using System.IO;
using Framework.Core;
using Xunit;

namespace Framework.Tests.Core.Recorder
{
    public class BinarySerializerTest
    {
        private readonly ISerializer target;

        public BinarySerializerTest()
        {
            target = new BinarySerializer();
        }

        [Fact]
        public void Should_serialize_deserialize()
        {
            using (var stream = new MemoryStream())
            {
                const string name = "pouet";
                target.Serialize(new Toto { Name = name }, stream);

                stream.Flush();
                stream.Seek(0, SeekOrigin.Begin);

                var actual = (Toto)target.Deserialize(stream);

                Assert.Equal(name, actual.Name);
            }
        }

        [Serializable]
        public class Toto
        {
            public string Name { get; set; }
        }
    }
}